<template>
  <div class="page-assets-redeem">
    <div class="baseDiv">
      <div class="datebox">
        <div>赎单日期</div>
        <div  class="date-pdding-left">
          <el-date-picker
            v-model="redeemDate"
            class="el-date-picker-zindex"
            type="date"

            value-format="yyyy-MM-dd"
            placeholder="选择日期">
          </el-date-picker></div>
        </div>
      <el-table class="product-table" border :header-cell-style="getHeaderCellClass" :data="allData.productListVos"
                style="width: 100%">
        <el-table-column  show-overflow-tooltip="true"  prop="id" label="编号" width="170">
        </el-table-column>
        <el-table-column  class="product-table-column"  prop="mainProductName" label="产品" >
        </el-table-column>
        <el-table-column prop="mainStandard" label="主标准" show-overflow-tooltip width="100">
        </el-table-column>
        <el-table-column prop="subStandard" label="二级标准" show-overflow-tooltip width="100">
        </el-table-column>
        <el-table-column prop="leftVolume" label="待赎数量(KG)" show-overflow-tooltip width="110">
        </el-table-column>
        <el-table-column prop="leftAmount" label="待赎资产" show-overflow-tooltip width="90">
        </el-table-column>
        <el-table-column prop="redeemVolume" label="出货数量(KG)" width="110">
          <template slot-scope="scope">
            <el-input size="mini" maxlength="10" @keyup.native="verifyDecimal(scope.row, 'redeemVolume')"  v-model="scope.row.redeemVolume"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="redeemAmount" label="赎单金额" width="100">
          <template slot-scope="scope" >
            <span v-if="scope.row.redeemVolume < scope.row.leftVolume">
              {{scope.row.redeemAmount=((scope.row.redeemVolume / scope.row.leftVolume) * scope.row.discountTotalAmount).toFixed(2)}}
            </span>
            <span v-if="scope.row.redeemVolume == scope.row.leftVolume">
              {{scope.row.redeemAmount=scope.row.discountTotalAmount - scope.row.tradeAmount}}
            </span>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script type="text/ecmascript-6">
  import maValidate from '@/utils/common-method/validate/index';
  // import {validateTips} from 'utils/tips';
  export default {
    components: {
    },
    props: {
      id: [String, Number] // 编辑项目的ID
    },
    data() {
      return {
         // 产品列表
        allData: {},
        redeemDate: null
      };
    },
    created() {
      this.getData();
    },
    methods: {
      // 定义表头的样式
      getHeaderCellClass({ row, column, rowIndex, columnIndex }) {
        if (rowIndex === 0) {
          return 'background: #ffffff; height: 34px; text-align: center !important; color: #1a1a1a !important;';
        } else {
          return '';
        }
      },
      getData() {
        let that = this;
        this.ajax({
          url: 'malisk/client/asset/assetProductList/' + that.id,
          loading: true,
          type: 'get',
          success: (res) => {
            setTimeout(() => {
              that.$pcNProgress.done();
            }, 300);
            that.allData = res.result;
          }
        });
      },
      // 校验小数
      verifyDecimal(row, prop) {
        if (row.redeemVolume > row.leftVolume) {
          // this.errorTip('出货数量不能大于待赎数量');
          row.redeemVolume = row.leftVolume;
        } else {
          maValidate.verifyDecimal(row, prop);
        }
      }
    }
  };
</script>
<style scoped>
  .page-assets-redeem {
    background-color: #ffffff;
    width: 100%;
    color: #1a1a1a;
    font-size: 14px;
  }

  .page-assets-redeem .baseDiv {
    width: 100%;
    height: auto;
    background-color: white
  }
  .page-assets-redeem .baseDiv .datebox{
    display: flex;
    justify-content: flex-start;
    align-items: center;
  }
  .page-assets-redeem .baseDiv .datebox .date-pdding-left{
    padding-left: 10px;
  }
  .page-import-project .baseDiv .el-form-item {
    display: inline-block;
    width: 400px;
    margin-left: 20px;
    margin-right: 20px;
    margin-bottom: 10px;
  }

  .page-assets-redeem .baseDiv  .product-table1 .product-table-column{
    background: #ffffff;
  }
  .page-assets-redeem .baseDiv  .product-table  {
    margin-top: 20px;
  }

  .page-assets-redeem .baseDiv  .product-table .el-table__body-wrapper {
    background: #ffffff !important;
  }

  .page-assets-redeem .baseDiv  .product-table .el-table--small td {
    text-align: center;
    background: #ffffff !important;
  }

  .page-assets-redeem .baseDiv  .product-table .el-table th {
    background-color: #fff !important;
  }

  .page-assets-redeem .baseDiv .product-table .el-table--small td {
    padding: 3px 0 !important;
  }
  .page-assets-redeem .baseDiv  .product-table .el-table tr {
    background-color: #fff !important;
  }
  .page-assets-redeem .baseDiv  .product-table .cell {
    line-height: 20px !important;
    text-align: center !important;
    color: #1a1a1a !important;
  }

  .page-assets-redeem .baseDiv  .baseDiv .el-input {
    width: 300px !important;
  }
  .page-assets-redeem .baseDiv .product-table .el-input__inner {
    text-align: center !important;
    height: 24px;
    line-height: 24px;
  }

  .page-assets-redeem .baseDiv  .goods-title {
    padding-left: 20px;
    height: 50px;
    line-height: 50px;
    width: 100%;
    margin-top: 20px;
    border-left: 1px solid #e5e5e5;
    border-right: 1px solid #e5e5e5;
    border-top: 1px solid #e5e5e5;
    background: white
  }

</style>
